<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="downloadsDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='downloadsDetail.heading'/>"/>
    <sx:head/>
</head>

<c:set var="delObject" scope="request"><fmt:message key="downloadsList.downloads"/></c:set>
<script type="text/javascript">var msgDelConfirm =
   "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<div class="span2">
    <h2><fmt:message key="downloadsDetail.heading"/></h2>
    <fmt:message key="downloadsDetail.message"/>
</div>

<div class="span7">
    <s:form id="downloadsForm" action="saveDownloads" method="post" validate="true" cssClass="well form-horizontal"  enctype="multipart/form-data">
	<s:hidden key="downloads.id"/>
    	<fieldset class="control-group">
    	<label class="control-label"> PostDate: </label>
    	<div class="controls">
    	<sx:datetimepicker  required="true" name="downloads.postDate" value="downloads.postDate"/>
    	<sx:datetimepicker  required="true" name="hourformat" value="hourformat" type="time"/>
    	</div>
		</fieldset>
        <s:select required = "true" name="downloads.systemuser.id" list="systemuserList" listKey="id" listValue="name"   label="Systemusers"></s:select>	
        <s:textfield key="downloads.title" required="false" maxlength="100" />
        <s:textfield key="downloads.viewTimes" required="true" maxlength="255" />
    	<c:if test="${not empty downloads.id}">
        <s:textfield key="downloads.filename" required="true" maxlength="100" />
    	<fieldset class="control-group">
    	<label class="control-label">  </label>
    	<div class="controls">
    			<a href="downloadsfile?downloadsid=<c:out value="${downloads.id}"/>" >Download this file</a>
    	</div>
		</fieldset>
        </c:if>
        <c:if test="${empty downloads.id}">
         <s:file label="Add file" name="downloadsfile"/>
        </c:if>

        <div id="actions" class="form-actions">
            <s:submit type="button" cssClass="btn btn-primary" method="save" key="button.save" theme="simple">
                <i class="icon-ok icon-white"></i> <fmt:message key="button.save"/>
            </s:submit>
            <c:if test="${not empty downloads.id}">
                <s:submit type="button" cssClass="btn btn-warning" method="delete" key="button.delete"
                    onclick="return confirmMessage(msgDelConfirm)" theme="simple">
                    <i class="icon-trash icon-white"></i> <fmt:message key="button.delete"/>
                </s:submit>
            </c:if>
            <s:submit type="button" cssClass="btn" method="cancel" key="button.cancel" theme="simple">
                <i class="icon-remove"></i> <fmt:message key="button.cancel"/>
            </s:submit>
        </div>
    </s:form>
    
    <c:if test="${not empty downloads.id}">
    <h2>Tags</h2>
    <s:form id="tagdownloadsForm" action="addDownloadsTag" method="post" validate="true" cssClass="well form-horizontal">
	        <s:hidden key="downloads.id"/>
	     	<s:select name="tag.id" list="tagList" listKey="id" listValue="tagname"></s:select>
	     	 <div id="actions" class="form-actions">
	        <s:submit type="button" cssClass="btn btn-primary" method="addDownloadsTag" key="button.save" theme="simple">
	            <i class="icon-ok icon-white"></i> add
	        </s:submit>
	        </div>
	</s:form>
    <display:table name="downloads.tags" class="table table-condensed table-striped table-hover" requestURI="" id="tagList" export="true" pagesize="25">
        <display:column property="id" sortable="true" href="editTag" media="html"
            paramId="id" paramProperty="id" titleKey="tag.id"/>
        <display:column property="id" media="csv excel xml pdf" titleKey="tag.id"/>
        <display:column property="tagname" sortable="true" titleKey="tag.tagname"/>
        <display:column>
           <s:form id="tagdownloadsForm" action="deleteDownloadsTag" method="post" validate="true">
			    <s:hidden key="downloads.id"/>
			    <s:hidden value="%{#attr.tagList.id}" name="tag.id"/>
			    <s:submit type="button" cssClass="btn btn-primary" method="deleteDownloadsTag" key="button.delete" theme="simple">
			        <i class="icon-ok icon-white"></i> delete
			    </s:submit>
			</s:form>
         </display:column>

        <display:setProperty name="paging.banner.item_name"><fmt:message key="tagList.tag"/></display:setProperty>
        <display:setProperty name="paging.banner.items_name"><fmt:message key="tagList.tags"/></display:setProperty>

        <display:setProperty name="export.excel.filename"><fmt:message key="tagList.title"/>.xls</display:setProperty>
        <display:setProperty name="export.csv.filename"><fmt:message key="tagList.title"/>.csv</display:setProperty>
        <display:setProperty name="export.pdf.filename"><fmt:message key="tagList.title"/>.pdf</display:setProperty>
    </display:table>
    </c:if>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("input[type='text']:visible:enabled:first", document.forms['downloadsForm']).focus();
    });
</script>
